package com.lframework.xingyun.basedata.controller;

import com.lframework.starter.web.core.annotations.security.HasPermission;
import com.lframework.starter.web.core.components.resp.InvokeResult;
import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
import com.lframework.starter.web.core.components.resp.PageResult;
import com.lframework.starter.web.core.controller.DefaultBaseController;
import com.lframework.xingyun.basedata.bo.member.QueryMemberLevelDetailBo;
import com.lframework.xingyun.basedata.service.member.MemberLevelDetailService;
import com.lframework.xingyun.basedata.vo.member.CreateMemberLevelDetailVo;
import com.lframework.xingyun.basedata.vo.member.QueryMemberLevelDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 会员等级生效明细 Controller
 *
 * @author mos
 */
@Api(tags = "会员等级生效明细")
@Validated
@RestController
@RequestMapping("/basedata/member-level-detail")
public class MemberLevelDetailController extends DefaultBaseController {

    @Autowired
    private MemberLevelDetailService memberLevelDetailService;

    /**
     * 查询列表
     */
    @ApiOperation("查询列表")
    @HasPermission({"base-data:member-level-detail:query"})
    @GetMapping("/query")
    public InvokeResult<PageResult<QueryMemberLevelDetailBo>> query(@Valid QueryMemberLevelDetailVo vo) {
        return InvokeResultBuilder.success(memberLevelDetailService.query(vo.getPageIndex(), vo.getPageSize(), vo));
    }

    /**
     * 新增
     */
    @ApiOperation("新增")
    @HasPermission({"base-data:member-level-detail:add"})
    @PostMapping
    public InvokeResult<Void> create(CreateMemberLevelDetailVo vo) {

        memberLevelDetailService.create(vo);

        return InvokeResultBuilder.success();
    }
}
